<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            安创入库确认
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">发货计划号</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请扫描发货计划号" id="deliveryPlanCode" value=""
                            onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">容器码</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请扫描容器码" id="containerCode" value=""
                            onclick="getIdSelector();" />
                    </div>
                </div>
            </li>
        </ul>
        <div style="padding-top:2%;"></div>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="search()">查询</div>

        <ul class="ui-selectee" id="tbodyHtml">

        </ul>
        <p></p>
        <p></p>

    </div>
    <div style="height:60px;"></div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    // 光标所在id
    var idSelector = "";

    // 初始化查询
    apiready = function () {
        $("#deliveryPlanCode").focus();
        idSelector = "deliveryPlanCode";
        search()
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //1：容器码
            if (idSelector == 'containerCode') {
                $("#containerCode").val(ret);
                //查询仓库
                search();

            }
        });
    }

    // 查询（模拟，无实际接口请求，仅前端模拟数据展示）
    function search() {
        var un = localStorage.getItem('un');
        var deliveryPlanCode = $("#deliveryPlanCode").val();
        var containerCode = $("#containerCode").val();
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                deliveryPlanCode: deliveryPlanCode,
                containerCode: containerCode,
                un: un
            }
        };
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getSnShippingPlanList";
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    // console.log('list:',JSON.stringify(myobj.list))
                    setTable(myobj.list)
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $api.html($api.byId("tbodyHtml"), "");
                }
            }
        });

        // 模拟返回数据
        var mockData = [
            {
                deliveryOrderCode: "1049900225",
                deliveryTime: "2025-09-12"
            },
            {
                deliveryOrderCode: "1049900225",
                deliveryTime: "2025-09-12"
            },
            {
                deliveryOrderCode: "1049900225",
                deliveryTime: "2025-09-12"
            },
            {
                deliveryOrderCode: "1049900225",
                deliveryTime: "2025-09-12"
            }
        ];

    }

    function setTable(list) {
        var html = "";
        for (var i = 0; i < list.length; i++) {
            html += "<div style='padding-top:1%;'></div>";
            html += "<li class='sortable ui-selectee ui-sortable' >";
            html += "<ul class='aui-list aui-media-list ui-selectee'>";
            html += "<li class='aui-list-item  ui-selectee' style='color: black !important;background-color: #FFFFFF !important;'>";
            html += "<div class='aui-media-list-item-inner ui-selectee ' >";
            html += "<div class='aui-list-item-inner ui-selectee '   onclick='showDetail(\"" + list[i].deliveryOrderCode + "\");'>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title '>发货单号:</div>";
            html += "<div class='aui-list-item-inner ui-selectee '>" + list[i].deliveryOrderCode + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>发货时间:</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].deliveryTime + "</div>";
            html += "</div>";
            html += "</div>";
            html += "</li>";
            html += "</ul>";
            html += "</li>";
        }
        $api.html($api.byId("tbodyHtml"), html);
    };

    // 显示详情（模拟）
    function showDetail(code) {
        api.openWin({
            name: 'productReceivedDetail',
            url: 'productReceivedDetail.html',
            pageParam: {
                deliveryOrderCode: code,
            }
        });
    }

    // 返回按钮
    function closeWin() {
        api.closeWin({});
    }

</script>


</html>